package com.bdqn.ch05.SZ.service.impl;


import com.bdqn.ch05.SZ.entity.User;
import com.bdqn.ch05.SZ.mapper.UserDao;
import com.bdqn.ch05.SZ.service.UserService;

/**
 * UserServiceImpl
 *
 * @aurhor Administrator  whs
 * @since 2024/7/10
 */
public class UserServiceImpl implements UserService {

//    private UserDao userDao = new UserDaoImpl();

    // 通过工厂获取所依赖的UserDao对象
//    private UserDao userDao = UserDaoFactory.getInstance();

    /**
     * 声明接口类型的引用，和具体实现类解耦合
     */
    private UserDao userDao ;


    /**
     * 保存用户信息
     * @param user
     */
    @Override
    public void save(User user) {
        //调用UserDao的方法保存用户信息
        userDao.save(user);
    }

    /**
     * dao 属性的 setter 访问器，会被 Spring调用 ， 实现设值注入
     * @param userDao
     */
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

}
